package com.shangma.util;

import org.springframework.aop.ThrowsAdvice;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @className: MyTask
 * @description:
 * @date:2021/12/22 14:55
 */
//@Component
public class MyTask {

//    @Scheduled(cron = "0/5 * * * * ?")
//    @Async
    public void task1(){
        System.out.println("当前线程是" + Thread.currentThread().getName() + "\t task1正在执行");
        try {
            Thread.sleep(20000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
//    @Scheduled(cron = "3/5 * * * * ?")
//    @Async
    public void task2(){
        System.out.println("当前线程是" + Thread.currentThread().getName() + "\t task2正在执行");
    }
}
